home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / toolbox / hilbert < prev    next >
Text File  |  1994-12-28  |  1KB  |  48 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Hilbert transform
  4.  
  5. // Syntax:      hilbert ( X )
  6.  
  7. // Description:
  8.  
  9. //      Hilbert computes the Hilbert transform of a real
  10. //      sequence. Hilbert returns a complex valued analytic function
  11. //      Z, such that:
  12.  
  13. //              Z = X + jXh
  14.  
  15. //      Where X is the original series, Xh
  16.  
  17. //      Properties: y = hilbert (x);
  18. //                  A = abs (y) is an envelope of x.
  19. //                  ph= angle (y) is the instaneous phase of x.
  20. //                  -N*eps < real (y)' * imag (y) < N*eps
  21.  
  22. //                  
  23. // Reference: J. S. Bendat, A. G. Piersol, Random Data, Analysis 
  24. //            and Measurement Procedures. 2nd Edition, 1986, 
  25. //            J. Wiley and Sons. 
  26.  
  27. // See Also: fft, ifft
  28.  
  29. //-------------------------------------------------------------------//
  30.  
  31. hilbert = function ( x )
  32. {
  33.   local (x)
  34.  
  35.   y = fft (real (x[:]));  # Make sure it is a vector.
  36.   n = y.n;
  37.   if (n != 1)
  38.   {
  39.     b = [1;                      # B_1(0) term
  40.          2*ones ((n-1)/2,1);     # f > 0
  41.          ones (1-mod(n,2),1);    # B_1(0) again (symmetric ?)
  42.          zeros ((n-1)/2,1) ];    # f < 0
  43.     y = b.*y;
  44.   }
  45.  
  46.   return ifft(y);
  47. };
  48.